package xyz.wpxy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.wpxy.domain.User;
import xyz.wpxy.service.UserService;

import java.util.List;

/**
 * @author 卫鹏
 * @Description
 * @createTime 2022年01月07日 21:32:00
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/findAll")
    public List<User> findAll() throws Exception {
        return userService.findAll();
    }

    @RequestMapping("/findByUserId/{id}")
    public User findByUserId(@PathVariable("id") Integer userId) throws Exception {
        return userService.findByUserId(userId);
    }

    @RequestMapping("/updateUser")
    public void updateUser(@RequestBody User user) throws Exception {
        userService.updateUser(user);
    }
}
